﻿using Knlght.Model.Sys;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knlght.Mappings
{
    public class SysDynamicMenuMapping : EntityTypeConfiguration<DynamicMenu>
    {
        public SysDynamicMenuMapping()
        {
            // 设置表名
            this.ToTable("Sys" + nameof(DynamicMenu));
            //设置主键
            this.HasKey(a => a.ID);
            //不自增
            this.Property(t => t.ID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            //不更新
            this.Property(t => t.AddTime).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
            //忽略列映射
            this.Ignore(p => p.Children);
            // 设置属性的类型和长度
            this.Property(a => a.ID).HasColumnType("NVarchar").HasMaxLength(200);
            this.Property(a => a.Title).HasColumnType("NVarchar").HasMaxLength(300);
        }
    }
}
